package com.winit.openapi.tms.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.tms.spi.common.CarrierService;
import com.winit.tms.spi.common.vo.CarrierVo;

/**
 * 承运人接口
 * 
 * @version <pre>
 * Author	Version		Date		Changes
 * bing.gu 	1.0  		2015年11月16日 	Created
 *
 * </pre>
 * @since 1.
 */
@Controller
@RequestMapping(value = "/tms/carrier")
public class CarrierController extends BaseController {

    @Resource
    private CarrierService carrierService;

    /**
     * 查询提货时间
     * 
     * @param requestMsg
     * @param responseMsg
     * @return
     */
    @RequestMapping(value = "/list")
    public String getAllCarriers(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
       
    	List<CarrierVo>  list= carrierService.getAllCarriers();
        Map<Object, Object> data = new HashMap<Object, Object>();
        List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
       
         for (CarrierVo carrierVo : list) {
	        Map<String, String> map = new HashMap<String, String>();
	         map.put("name", carrierVo.getCarrierName());
	         map.put("code", carrierVo.getCarrierCode());
	         resultList.add(map);
         }
        data.put("carrierList", resultList);
        responseMsg.setData(data);
        return SUCCESS;
    }
}
